<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/15
 * Time: 16:05
 */
$key=$_COOKIE['userkey'];
session_start();
if(!isset($_SESSION[$key])){
    echo '<a href="../login/loginUI.php">请重新登陆</a>';
    die;
}
$RealName=$_POST['RealName'];
$AccountCode=$_POST['AccountCode'];
echo '欢迎您：'.$RealName;
echo '<br/>';
$conn=new  mysqli();
$conn->connect('127.0.0.1','root','root','bank');
$sql="SELECT * FROM bankcard WHERE AccountId=(
 SELECT AccountId FROM accountinfo WHERE AccountCode='$AccountCode' AND RealName='$RealName'
) and CardState=0;";
$result=$conn->query($sql);
$data=[];
$n=$conn->affected_rows;
if($n>0){
    $a=0;
    for ($i=0;$i<$n;$i++) {
        $a++;
        $data[$i] = $result->fetch_assoc();
        echo '第'.$a.'张卡的卡号：'.$data[$i]['CardNo'] .' 卡余额：'.$data[$i]['CardMoney']. '<br/>';
    }
}
else{
    echo '未查找到相关信息<a href="delete_card.php">返回查询页面</a>><br/>';
    die();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>请输入你要删除的卡号</h1>
<form method="post" action="deletecard_action2.php" >
    <input type="text" name="CardNo" placeholder="请输入你要删除的卡号"><br/>
    <input type="submit"><br/>
</form>
<a href="delete_card.php"><button>返回查询页面</button></a>
<a href="../login/loginAction.php"><button>返回主页面</button></a><br/>
</body>
</html>
